var api = require('../../utils/api.js');
var app = getApp();
Page({
    data: {
        list: [],
        activeTab: 'all',
        tabs: [{
                name: '全部',
                type: 'all'
            },
            {
                name: '收入',
                type: 'income'
            },
            {
                name: '支出',
                type: 'expense'
            },
        ],
        records:[]
    },
    onLoad(params) {
        
    },
    onShow() {
        var that=this;
        api.post({
            url: 'user/index' ,
            data: {},
            success: data => {
                console.log(data);

                that.setData({
                    user:data.data
                })
               
            }
        })


        this.getmymoneylog();
    },

    getmymoneylog(){
        var that=this;
        var activeTab=this.data.activeTab;

        api.post({
            url: 'money/getallmoneylog' ,
            data: {'activeTab':activeTab},
            success: data => {
                console.log(data);

                that.setData({
                    records:data.data
                })
               
            }
        })

    },

    switchTab(ret) {
        console.log(ret);
        var type = ret.currentTarget.dataset.type;

        this.setData({
            activeTab: type
        })

        this.getmymoneylog();
    }

});